package com.gs.SynPatrolRep.dialog;

import android.content.Context;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.gs.SynPatrolRep.R;

public class CancelDialog extends BaseDialog {

    private EditText etRemark;
    private String billNum;
    private int title;

    public CancelDialog(@NonNull Context context,int title, String billNum, IDoneListener iDoneListener) {
        super(context, R.style.toast_dialog);
        this.title = title;
        this.billNum = billNum;
        this.iDoneListener = iDoneListener;
    }

    @Override
    public void refreshView() {

    }

    @Override
    public void initView() {
        TextView tvTitle = findViewById(R.id.tv_title);
        tvTitle.setText(title);
        TextView tvCon = findViewById(R.id.tv_num);
        tvCon.setText(billNum);
        etRemark = findViewById(R.id.et_remark);
        OnClickListener onClickListener = new OnClickListener();
        findViewById(R.id.btn_cancel).setOnClickListener(onClickListener);
        findViewById(R.id.btn_ok).setOnClickListener(onClickListener);
    }

    class OnClickListener implements View.OnClickListener {

        @Override
        public void onClick(View v) {
            switch (v.getId()) {
                case R.id.btn_cancel:
                    dismiss();
                    break;
                case R.id.btn_ok:
                    iDoneListener.getDoneFromDialog(etRemark.getText().toString());
                    dismiss();
                    break;
            }
        }
    }

    @Override
    public int getLayoutId() {
        return R.layout.dialog_cancel;
    }

    private IDoneListener iDoneListener;

    public interface IDoneListener {
        void getDoneFromDialog(String remark);
    }
}
